home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5505 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: pegasus.montclair.edu!harmon
  2. From: harmon@pegasus.montclair.edu (Derek Harmon)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: simple code, argc, argv, strcmp()
  5. Date: 1 Feb 1996 13:08:37 -0500
  6. Organization: Montclair State University
  7. Message-ID: <harmon.823197381@pegasus.montclair.edu>
  8. References: <11f7cc$17261a.3b3@daprez>
  9. NNTP-Posting-Host: pegasus.montclair.edu
  10. Keywords: strcmp encode decode argc argv
  11. X-Newsreader: NN version 6.5.0 #68 (NOV)
  12.  
  13. otisg@panther.middlebury.edu (Otis Gospodnetic) writes:
  14. >  if (!strcmp(argv[1],"-d") || !strcmp(argv[1],"-e")) {
  15. >    Usage();
  16. >  }
  17.  
  18.    This is where your troubles lie.  Let's think for a second, if argv[1]
  19. is "-d", then the first clause is false.  BUT, if argv[1] is "-d" then it
  20. cannot also be "-e", so the second clause is true, and Usage() is called.
  21. On the other hand, if argv[1] is "-e", then the second clause is false.
  22. Unfortunately, argv[1] is then surely not "-d", and the first clause is true.
  23.  
  24.    Therefore, I would suggest that you only call Usage() when argv[1] is
  25. not "-d" AND not "-e":
  26.  
  27. :   if (!strcmp(argv[1],"-d") && !strcmp(argv[1],"-e")) {
  28.  
  29.                                                   -- Stone
  30. --
  31. ... Your program is sick!  Shoot it and put it out of its memory.
  32.  
  33.  
  34.  
  35.